package com.cy.pj.module.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ModelViewController {
    @RequestMapping("/doModelAndView")
    public String doModelAndView(Model model) {
        model.addAttribute("username", "jason");
        model.addAttribute("state", true);
        return "view";
    }

    @RequestMapping("/doModelAndView01")
    public ModelAndView doMoedlAndView(ModelAndView mv) {
        mv.addObject("name", "jason");
        mv.addObject("state", true);
        mv.setViewName("view");
        return mv;
    }

    @RequestMapping("/doModelAndView02")
    public ModelAndView doMoedlAndView02(ModelAndView wb) {
        List<String> list = new ArrayList<String>();
        list.add("北京");
        list.add("上海");
        list.add("深圳");
        wb.addObject("citys", list);
        wb.setViewName("view");
        return wb;
    }
}
